home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / pwd / c / putpwent < prev    next >
Text File  |  1996-11-09  |  1KB  |  45 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/pwd/c/RCS/putpwent,v $
  4.  * $Date: 1996/10/30 22:04:51 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: putpwent,v $
  10.  * Revision 1.1  1996/10/30 22:04:51  unixlib
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. static const char rcs_id[] = "$Id: putpwent,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
  16.  
  17. /* pwd.c.putpwent. Write an entry to stream.
  18.  
  19.    System V compatibility function.
  20.    Written by Nick Burrett, 13 October 1996.  */
  21.  
  22. #include <errno.h>
  23. #include <stdio.h>
  24. #include <pwd.h>
  25.  
  26. /* Write an entry to the given stream.
  27.    This must know the format of the password file.  */
  28. int
  29. putpwent (const struct passwd *p, FILE *stream)
  30. {
  31.   if (p == NULL || stream == NULL)
  32.     {
  33.       errno = EINVAL;
  34.       return -1;
  35.     }
  36.  
  37.   if (fprintf (stream, "%s:%s:%u:%u:%s:%s:%s\n",
  38.            p->pw_name, p->pw_passwd,
  39.            p->pw_uid, p->pw_gid,
  40.            p->pw_gecos, p->pw_dir, p->pw_shell) < 0)
  41.     return -1;
  42.  
  43.   return 0;
  44. }
  45.